﻿/*
 * MIT License
 *Copyright (c) 2021 咖啡与网络(java-and-net)
 *
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using CoreShop.Library;
using CoreShop.Model;
using CoreShop.Repository;
using SqlSugar;

namespace CoreShop.Services
{
    /// <summary>
    /// 单据编码实现
    /// </summary>
    public class corecmsnumberdetailService : Repository<corecmsnumberdetail>, IcorecmsnumberdetailService
    {
        #region 支付信息

        

        /// <summary>
        /// 更新商品分类 删除标志
        /// </summary>
        /// <param name="custo"></param>
        /// <returns></returns>
        public bool UpdDataInfo(corecmsnumberdetail entry)
        {
            var bl = base.Update(a => new corecmsnumberdetail()
            {
                lastNumber = entry.lastNumber,
                numberDate = entry.numberDate,
                classId = entry.classId,
            }, a => a.numberType == entry.numberType);
            return bl;
        }
    

        /// <summary>
        /// 根据商品分类Id查询商品分类信息
        /// </summary>
        /// <param name="CustoNo"></param>
        /// <returns></returns>
        public corecmsnumberdetail SelectDataById(Int32 numberType)
        {
            corecmsnumberdetail model = base.GetFirst(a => a.numberType == numberType);
            if (model == null)
            {
                model = new corecmsnumberdetail();
                model.numberType = numberType;
                model.lastNumber = 0;
                model.numberName = EnumHelper.GetDescByValue<GlobalEnumVars.SerialNumberType>(numberType);
                model.numberDate = DateTime.Now;
                model.classId = 0;
                base.Insert(model);
            }
            return model;
        }
        #endregion
    }
}
